#include <iostream>

#include "message_connection_socket.h"

MessageConnectionSocket::MessageConnectionSocket( int nFD ) throw()
:
	ConnectionSocket( nFD )
{
}

void MessageConnectionSocket::SendMessage( connection::PlainTextMessage* pMsg, connection::PlainTextSerializer* pSerializer )
{
	Send( pSerializer->Serialize( pMsg ) );
}

connection::PlainTextMessage* MessageConnectionSocket::ReceiveMessage( connection::PlainTextSerializer* pSerializer )
{
	std::string sMessage;
	Receive( sMessage );

	return dynamic_cast<connection::PlainTextMessage*>(pSerializer->Deserialize( sMessage ));
}

